package wzh.crm.ui;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.LinearLayout;

import java.io.Serializable;
import java.util.List;

/**
 * Created by wangzehao on 2016/5/23.
 */
public class DisplayListView<T extends Serializable> extends LinearLayout{
    public DisplayListView(Context context, AttributeSet attrs) {
        super(context, attrs);
        this.setOrientation(LinearLayout.VERTICAL);
    }

    public void setModel(List<T> model) {
        this.removeAllViews();
        for(T vo:model){
            DisplayListItemView<T> itemView= getNewViewInstanceForModel();
            itemView.setModel(vo);
            this.addView(itemView);
        }
    }

    protected DisplayListItemView<T> getNewViewInstanceForModel(){
        return new DisplayListItemView(getContext(),null);
    }

}
